Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
WglDisplay::releasePbuffer() returns early when wglReleasePbufferDC()
fails. At that point, releaseDC() has already set the DC as released.
The pbuffer stays in mLivePbufs. It is not reused and not destroyed.
createPbufferSurface() refills an empty pool with max(live, 8) new
pbuffers. Each stuck pbuffer increases the live count, so the pool
doubles again and again. On NVIDIA, each pbuffer has a hidden
NVOpenGLPbuffer window. Window operations on the full desktop become
slow.
The surface is not in use after release. Thus, always move the pbuffer
to the free list. When the pool gives the pbuffer again, refreshDC()
gets a new DC. If that fails, the pbuffer goes to mDeletePbufs, as
before. Log the failure, with a limit on the number of messages.
Test: Android Emulator 37.2.13, Windows 11, NVIDIA RTX 4070 Laptop,
-gpu host, 16 UI test flows, then a framework restart. The
emulator DLL cannot be built from main, so the test used the
shipped DLL with the early return removed (no log).
NVOpenGLPbuffer windows: 68 -> 297 without the change,
43 -> 41 with it. GDI objects: 137 -> 367 without, 107 -> 109
with. Stuck pbuffers (live, no owner) after 8 flows: 76 without,
0 with.
Assisted-by: Claude Code:Claude-Opus-5.5
RieBi
force-pushed
the
wgl-pbuffer-release-leak
branch
from
November 17, 2026 19:45
85ec7eb to
5c9f7fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #238.
WglDisplay::releasePbuffer()returns early whenwglReleasePbufferDC()fails. The pbufferstays in
mLivePbufs. It is not reused and not destroyed. Each refill of the pool uses the livecount, so the pool doubles again and again. On NVIDIA, each pbuffer has a hidden window.
Fix
wglReleasePbufferDC()fails.refreshDC()gets a new DC. If that fails, the pbuffergoes to
mDeletePbufs. This path does not change.GetLastError(). Log the first 8 failures, then only at powers of two.Test
Android Emulator 37.2.13, Windows 11, NVIDIA RTX 4070 Laptop,
-gpu host. 16 UI test flows,then a framework restart.
The emulator DLL cannot be built from
main: it does not exportandroid_setOpenglesRenderer.Thus, the test used the shipped DLL with the early return removed (2 bytes). This has the same
behavior as this change, without the log.
NVOpenGLPbufferwindows, without changeNVOpenGLPbufferwindows, with changeWithout the change, 76 pbuffers had no owner after 8 flows. The GDI count with the change is
stable. Thus, the reuse of a pbuffer after a failed release does not leak DCs.
egl_os_api_wgl.cppcompiles with clang-cl (CMake, Windows). There are no unit tests for theWGL back end.
Related
#200 adds
m_locktodrainGlRenderThreadResources(). It can remove one cause of the failedrelease. This change is necessary also with #200: any other failure has the same leak.
This change was developed with AI assistance (Claude Code; see the
Assisted-bytrailer).